import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../config/bloc_view_model.dart';
import '../../config/conter_view_model.dart';
import 'package:flutter_bloc/flutter_bloc.dart';

class SettingPage extends StatefulWidget {
  SettingPage({Key? key}) : super(key: key);

  @override
  _SettingPageState createState() => _SettingPageState();
}

class _SettingPageState extends State<SettingPage> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    // final counterViewModel = Provider.of<LDXCounterViewModel>(context);
    final counterViewModel = BlocProvider.of<CounterBloc>(context);

    return Container(
        child: Scaffold(
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                // Consumer<LDXCounterViewModel>(builder: (context, countPage, child) {
                //   return Text("${countPage.countPage}");
                // }),
                BlocBuilder<CounterBloc, int>(
                  builder: (context, count) {
                    return Text('Count: $count');
                  },
                ),
                ElevatedButton(
                  style: const ButtonStyle(
                    foregroundColor: WidgetStatePropertyAll(Colors.white),
                    backgroundColor: WidgetStatePropertyAll(Colors.orange),
                  ),
                  onPressed: () {
                    context.read<CounterBloc>().add(-1);
                    // counterViewModel.add(CounterIncrementPressed());
                    // counterViewModel.countPage = 1000;
                  },
                  child: const Text("登 录"),
                )
              ],
            ),
          ),
        ));
  }
}
